package com.ybu.service.impl;

import com.ybu.common.ServiceCode;
import com.ybu.common.ServiceException;
import com.ybu.mapper.OrderMapper;
import com.ybu.pojo.vo.UserLoginVO;
import com.ybu.pojo.vo.OrderVO;
import com.ybu.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

      @Override
    public List<OrderVO> getOrderList(UserLoginVO userLoginVO) {
        List<OrderVO> orderList = orderMapper.getOrderList(userLoginVO.getId());
        if(orderList==null || orderList.size()==0){
            throw new ServiceException(ServiceCode.ERR_NOT_FOUND,"该用户没有订单");
        }
        return orderList;
    }
}
